﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.TK
{
    class Class8
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("重大疾病"))
            {

                string a = ppa.PolicyActing.Policy.SelectedColRateFactors["领取年龄"].Trim();

                int receiveAge = 0;

                if (a == "50岁")
                    receiveAge = 50;
                else if (a == "55岁")
                    receiveAge = 55;
                else if (a == "60岁")
                    receiveAge = 60;
                else if (a == "65岁")
                    receiveAge = 65;
                else if (a == "70岁")
                    receiveAge = 70;


                if (ppa.Period == 0)
                {
                    da.Value = ppa.TotalFee;
                    ppa.IsCurrentFinish = true;
                }
                else if (ppa.Period > 0)
                {
                    IPolicyPeriodActing bpa = ppa.SchemePeriodActing.BasicPolicyPeriodActing;

                    if (ppa.Age < receiveAge)
                    {
                        da.Value = bpa.Amount > bpa.TotalFee ? bpa.Amount : bpa.TotalFee;
                    }
                    else
                    {
                        double x = bpa.GetDutyTotalValue("生存保险金");
                        da.Value = bpa.Amount - x > bpa.TotalFee - x ? bpa.Amount - x : bpa.TotalFee - x;
                    }

                    bpa.IsCurrentFinish = true;
                    ppa.IsCurrentFinish = true;
                }
            }
        }
    }
}
